Skip to content

refactor!: migrate class-validator to zod#26597

Merged
danieldietzler merged 6 commits intomainfrom
refactor/zod-migration
Apr 14, 2026
Merged

refactor!: migrate class-validator to zod#26597
danieldietzler merged 6 commits intomainfrom
refactor/zod-migration

Conversation

@timonrieger
Copy link
Copy Markdown
Collaborator

@timonrieger timonrieger commented Feb 28, 2026

see #26172 for the implementation proposal and #26427 for the first partial migration try.

As discussed, the migration effort is signifcantly lower and less akward when done in one go. This is the PR that does this!

I have iterated over this PR over and over again locally to get this as best as possible. This PR has been separated into 6 commits, one doing the actual server-side migration, one for tiny web, mobile and cli type fixes (unavoidable as explained in my review), the regeneration of the openapi spec/dart and ts clients and the removal of the class-validator dependency. This approach should help making this reviewable.

I tested the whole stack locally, server, web and mobile, going through plenty of views myself to check that it all works and no bugs are introduced. More testing from others is appreciated tho!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 28, 2026

Preview environment has been removed.

Copy link
Copy Markdown
Collaborator Author

@timonrieger timonrieger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in Zod semantics, .default(x) means “if the input is undefined, substitute x”, so the schema must accept undefined, which effectively makes that value optional-at-input. this causes the generated clients to mark these response properties as optional, but they always do have a value. Thus enforcing the type in ts is fine. All changes in the web commit relate to that.

Comment thread mobile/lib/infrastructure/repositories/sync_stream.repository.dart Outdated
Comment thread mobile/lib/repositories/album_api.repository.dart
Comment thread mobile/lib/domain/utils/migrate_cloud_ids.dart Outdated
Copy link
Copy Markdown
Collaborator Author

@timonrieger timonrieger Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additional tests for the feature introduced in #26532 and tests the zod implementation for it

Comment thread server/src/database.ts
hideAt: Date | null;
type: MemoryType;
data: object;
data: Record<string, unknown>;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no runtime effect, but necessary for types to work out

@timonrieger timonrieger force-pushed the refactor/zod-migration branch from 5f3615e to d2529af Compare February 28, 2026 18:06
Comment thread e2e/src/specs/server/api/person.e2e-spec.ts Outdated
@timonrieger timonrieger force-pushed the refactor/zod-migration branch 3 times, most recently from 6dd4a89 to 68d08fb Compare February 28, 2026 20:36
Comment thread server/src/utils/date.ts Outdated
Comment thread e2e/src/ui/generators/timeline/timeline-config.ts Outdated
Comment thread e2e/src/specs/server/api/asset.e2e-spec.ts
Comment thread mobile/lib/domain/utils/migrate_cloud_ids.dart
@timonrieger timonrieger marked this pull request as ready for review February 28, 2026 21:26
Comment thread server/src/dtos/exif.dto.ts
@timonrieger timonrieger force-pushed the refactor/zod-migration branch 3 times, most recently from 48f6dd9 to 7aad864 Compare March 2, 2026 14:44
Comment thread mobile/openapi/lib/api/activities_api.dart
Comment thread open-api/typescript-sdk/src/fetch-client.ts Outdated
Comment thread open-api/typescript-sdk/src/fetch-client.ts Outdated
Comment thread open-api/typescript-sdk/src/fetch-client.ts Outdated
Comment thread server/package.json
@timonrieger timonrieger force-pushed the refactor/zod-migration branch from 7aad864 to 1df08ce Compare March 6, 2026 22:39
@timonrieger timonrieger force-pushed the refactor/zod-migration branch 2 times, most recently from 60dfcc0 to 803fbfe Compare March 10, 2026 15:48
@immich-push-o-matic immich-push-o-matic bot added the cli Tasks related to the Immich CLI label Mar 10, 2026
@timonrieger timonrieger force-pushed the refactor/zod-migration branch from 803fbfe to bec91e9 Compare March 13, 2026 15:37
@timonrieger timonrieger force-pushed the refactor/zod-migration branch 2 times, most recently from caef2b7 to 31c3f2d Compare March 24, 2026 13:50
@timonrieger timonrieger force-pushed the refactor/zod-migration branch 2 times, most recently from 2072dc8 to 182b738 Compare April 5, 2026 21:52
Copy link
Copy Markdown
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must've been so much work, dang. Thank you!

Comment thread e2e/src/ui/generators/timeline/timeline-config.ts Outdated
Comment thread open-api/immich-openapi-specs.json Outdated
Comment thread open-api/immich-openapi-specs.json
Comment thread open-api/immich-openapi-specs.json Outdated
Comment thread open-api/immich-openapi-specs.json
Comment thread server/src/dtos/user.dto.spec.ts Outdated
Comment thread server/src/dtos/user.dto.spec.ts Outdated
Comment thread server/src/dtos/user.dto.ts
Comment thread server/src/dtos/user.dto.ts Outdated
Comment thread server/src/services/server.service.ts
@timonrieger timonrieger force-pushed the refactor/zod-migration branch from 182b738 to a2f9bd2 Compare April 10, 2026 21:39
Copy link
Copy Markdown
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, last few notes from my end :)

Comment thread server/src/dtos/memory.dto.ts Outdated
Comment thread server/src/dtos/person.dto.ts
@timonrieger timonrieger force-pushed the refactor/zod-migration branch from a2f9bd2 to 8a7cc61 Compare April 14, 2026 20:51
Copy link
Copy Markdown
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job! Thank you so much for putting all the effort in!

@danieldietzler danieldietzler changed the title refactor: migrate class-validator to zod refactor!: migrate class-validator to zod Apr 14, 2026
@danieldietzler danieldietzler merged commit 7d8f843 into main Apr 14, 2026
70 of 71 checks passed
@danieldietzler danieldietzler deleted the refactor/zod-migration branch April 14, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants